package kingdee;

import _1._0._0._127.ormrpc.services.EASLogin.EASLoginProxy;
import _1._0._0._127.ormrpc.services.EASLogin.EASLoginProxyService;
import _1._0._0._127.ormrpc.services.EASLogin.EASLoginProxyServiceLocator;
import client.WSContext;
import cn.hutool.core.lang.Console;
import cn.hutool.core.net.url.UrlBuilder;
import cn.hutool.core.util.URLUtil;
import lombok.SneakyThrows;
import lombok.experimental.UtilityClass;

import java.net.URL;

@UtilityClass
public class Test {

    public final static String HTTP = "http";
    public final static String SERVER_SUFFIX_URL = "/ormrpc/services";
    public final static String SLN_NAME = "eas";
    public final static String LANGUAGE = "l2";

    @SneakyThrows
    public WSContext login(String host, String user, String passwd, String dbcode, int dbtype) {
        // ----------------------登录-----------------------------------
        URL endpoint = URLUtil.url(host + "/EASLogin");

        EASLoginProxy proxy = new EASLoginProxyServiceLocator().getEASLogin(endpoint);

        WSContext ctx = proxy.login(user, passwd, "eas", dbcode, "l2", dbtype);
        return ctx;
    }

    public static void main(String[] args) {

        Console.log(WSEASVersionUtil.getVersion("192.168.2.203", 6888));
        String url = UrlBuilder.create()
                .setScheme("http")
                .setHost("192.168.2.203").setPort(6888)
                .addPath("/ormrpc/services")
                .build();

        Console.log(login(url, "user", "kduser", "75demo", 0).getSessionId());
    }
}
